'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema;

var ShareSchema = new Schema({
  _user: Schema.Types.Mixed,
  title: {
    type: String,
    required: true
  },
  file_name: {
    type: String,
    required: true
  },
  file_path: {
    type: String,
    required: true
  },
  file_size: {
    type: String,
    required: true
  },
  file_type: {
    type: String,
    default: 'unknown'
  },
  file_status: {
    type: String,
    default: 'public'
  },
  created_at: {type: Date, default: Date.now},
  updated_at: {type: Date, default: Date.now}
});

ShareSchema
  .pre('save', function(next) {
    if (!this.isNew) this.updated_at = Date.now;
    next();
  });
module.exports = mongoose.model('Share', ShareSchema);
